program example
use polymorphic_complextaylor
implicit none 
integer no,nv,n,i
type(complextaylor) f,g
complex(dp) c,cc
integer, allocatable :: j(:),k(:),jj(:)

no=6; nv= 4;    ! no: the order of the polynomial    nv: the number of variables   
call init(no,nv)  ! initializes taylor series without maps

call alloc(f,g)      ! must be constructed after init

c=cmplx(5.d0,-1.4d0,kind=dp)
cc=cmplx(6.d0,1.6d0,kind=dp)  



n=2
allocate(j(nv),k(n),jj(nv)) 

j=0
j(1)=1;j(2)=2;j(3)=2;j(4)=1;

jj=0
jj(1)=1;jj(2)=1;jj(3)=0;jj(4)=3;


k=0
do i=1, n
    k(i)=j(i)
end do

f=(c.mono.j )+ (cc.mono.jj ) + 3.d0  !  <--------------------  constant number changed
      !  Creates (5.d0 x_1 x_ 2 ^2 x_3^2 x_ 4 - 1.4d0 i*  x_1 x_ 2 ^2 x_3^2 x_ 4)
	  !                  + (6.d0 x_1 x_ 2  x_ 4^3 + 1.6d0 i* x_1 x_ 2  x_ 4^3) + 3.d0
g=f.par.k           !  Creates 5.d0 x_3^2 x_4 - 1.4d0 i*   x_3^2 x_ 4
call print(f,6)
call print(g,6)

deallocate(j,k,jj)



f=(c.mono.'1111' ) + (c.mono.'201' ) + ( cc.mono.'1112') + 3.d0  !  <--------------------  constant number changed
     ! Creates (5.d0 x_1 x_ 2 x_3 x_ 4 - 1.4d0 i* x_1 x_ 2 x_3 x_ 4) + (5.d0 x_1^2  x_3 - 1.4d0 i* x_1^2  x_3) 
	 !                  + (6.0d0 x_1 x_ 2 x_3 x_ 4^2 + 1.6d0 i*x_1 x_ 2 x_3 x_ 4^2) + 3.d0 
g=f.par.'11'        ! Creates (5.d0 x_3 x_ 4 - 1.4d0 i* x_3 x_ 4) + (6.0d0  x_3 x_ 4^2 + 1.6d0 i* x_3 x_ 4^2) 

call print( f,6)
call print(g,6)




call kill(f,g)      ! must be destroyed
end program example